<?php
if($_GET)
{
$Page = $_GET['page'];
$cat=$_GET['from'];
$per_page = 5;
$Prev_Page = $Page - 1;
$Next_Page = $Page + 1;
$Page_Start = (($per_page * $Page) -$per_page);
include('connection.php');

$sql = "SELECT * FROM  `student information` WHERE `full_name` LIKE '$cat%'  LIMIT $Page_Start, $per_page";
$result = mysql_query($sql,$con);

while($row = mysql_fetch_array($result))
{
	 echo "<div class='' '>"; 
 echo "<div style=''>";
  echo"<img src='studentprofileimage/".$row['photo']."' style='height:70px; width:50px; '  >";
  echo "<div> Student ID-".$row['student_id']."</div>";
echo "</div>";
	echo "<div  style=''>";   
echo "<table>";
	echo "<tr><td>Name:</td><td>".$row['full_name'] .  "</td>";
	
echo "</table>";


echo"</div>"; 
echo "<a href='profile.php?id=$row[student_id]' class='moredetail'>More Details</a> ";


	echo"</div>";

}


/* ---------------Calculating the starting and endign values for the loop----------------------------------- */
$strSQL= "SELECT * FROM   `student information` WHERE `full_name` LIKE '$cat%'";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);
if ($Num_Rows <= $per_page) {
    $Num_Pages = 1;
} elseif (($Num_Rows % $per_page) == 0) {
    $Num_Pages = ($Num_Rows / $per_page) ;
} else {
    $Num_Pages = ($Num_Rows / $per_page) + 1;
    $Num_Pages = (int) $Num_Pages;
}

$Prev_Page = $Page - 1;
$Next_Page = $Page + 1;
if($Prev_Page !=0 )
{
	 echo " <input type='button' class='searchbutton' value='Prev'  onclick=getdata('$cat','$Prev_Page')> ";
	}
	
for ($i=1; $i <= $Num_Pages; $i++) {
    if ($i != $Page) {
		
        echo " <input type='button' class='searchbutton'  value='$i' onclick=getdata('$cat','$i')> ";
    } else {
		
        echo "<span class='searchbutton' ><b>  $i </b></span>"; 
    }
}
if($Page !=$Num_Pages)
{
	 echo " <input type='button'  value='Next' class='searchbutton' onclick=getdata('$cat','$Next_Page')> ";
	}
	
mysql_close($con);
}
?>